import pymongo
import pandas as pd

# 连接到 MongoDB
client = pymongo.MongoClient("mongodb://localhost:27017/")
db = client["db_data"]
collection = db["product_data"]

# 查找集合中的所有文档
documents = collection.find()

# 将文档转换为 DataFrame
df = pd.DataFrame(list(documents))
print(df.head())